<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<div class="bjui-pageContent">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">
                提醒
            </h3>
        </div>
        <div class="panel-body bjui-doc" style="padding:0;">
            <div data-layout-h="0" class="bjui-row col-2">
                <div class="row-input">
                    <ul>
                        <li>今日还款：<a href="javascript:repayingNavTab();">${pagingRepayByToday.totalCount}</a></li>
                    </ul>
                </div>
                <div class="row-input">
                    <table class="table table-bordered">
                        <thead>
                        <tr>
                            <td align="center">标的编号</td>
                            <td align="center">借款人</td>
                            <td align="center">应还本金</td>
                            <td align="center">应付利息</td>
                            <td align="center">逾期罚息</td>
                            <td align="center">应还金额</td>
                        </tr>
                        </thead>
                        <tbody>
                        <c:set var="buyMoneyD_sum" value="0"/>
                        <c:set var="interestD_sum" value="0"/>
                        <c:set var="overD_sum" value="0"/>
                        <c:set var="realRepayMoneyD_sum" value="0"/>
                        <c:forEach items="${pagingRepayByToday.list}" var="todayRepay">
                            <tr>
                                <td>
                                    <a href="javascript:loanInfo(${todayRepay.loanId});">
                                            ${todayRepay.loanNumber}
                                    </a>
                                </td>
                                <td>
                                    <a href="javascript:userInfo(${todayRepay.loanUserId},'${todayRepay.loanUserName}');">
                                            ${todayRepay.loanUserName}
                                    </a>
                                </td>
                                <td>
                                    <fmt:formatNumber value="${todayRepay.shouldRepayMoneyD-todayRepay.interestD}"
                                                      pattern="####0.00"/>
                                </td>
                                <td>
                                    <fmt:formatNumber value="${todayRepay.nowInterestD}" pattern="####0.00"/>
                                </td>
                                <td>
                                    <fmt:formatNumber value="${todayRepay.overD}" pattern="####0.00"/>
                                </td>
                                <td>
                                    <fmt:formatNumber value="${todayRepay.realRepayMoneyD}" pattern="####0.00"/>
                                </td>
                            </tr>

                            <c:set value="${buyMoneyD_sum + todayRepay.shouldRepayMoneyD-todayRepay.nowInterestD}"
                                   var="buyMoneyD_sum"/>
                            <c:set value="${interestD_sum + todayRepay.nowInterestD}" var="interestD_sum"/>
                            <c:set value="${overD_sum + todayRepay.overD}" var="overD_sum"/>
                            <c:set value="${realRepayMoneyD_sum + todayRepay.realRepayMoneyD}"
                                   var="realRepayMoneyD_sum"/>
                        </c:forEach>
                        </tbody>
                        <tfoot>
                        <tr>
                            <td colspan="5"></td>
                            <td>
                                <a href="javascript:repayingNavTab();">更多...</a>
                            </td>
                        </tr>
                        <tr>
                            <td>合计:</td>
                            <td></td>
                            <%--<td><fmt:formatNumber value="${realRepayMoneyD_sum-interestD_sum}"--%>
                            <%--pattern="####0.00"/></td>--%>
                            <td><fmt:formatNumber value="${buyMoneyD_sum}" pattern="####0.00"/></td>
                            <td><fmt:formatNumber value="${interestD_sum}" pattern="####0.00"/></td>
                            <td><fmt:formatNumber value="${overD_sum}" pattern="####0.00"/></td>
                            <td><fmt:formatNumber value="${realRepayMoneyD_sum}" pattern="####0.00"/></td>
                        </tr>
                        </tfoot>
                    </table>
                </div>
            </div>
            <div class="page-header"></div>
            <div data-layout-h="0" class="bjui-row col-1">
                <div class="row-input">
                    <ul>
                        <li>
                            满标待放款：<a href="javascript:fullPayNavTab();">${fullPayCount}</a>
                        </li>
                        <li>
                            流标待返款：<a href="javascript:riverNavTab();">${riverCount}</a>
                        </li>
                        <li>
                            发标待审核：<a href="javascript:firstCheckNavTab();">${firstCheckCount}</a>
                        </li>
                        <li>
                            问题标的：<a href="javascript:loaningNavTab();">${loanStopCount}</a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">
                融资
            </h3>
        </div>
        <div class="panel-body bjui-doc" style="padding: 0;">
            <div data-layout-h="0" class="bjui-row col-2">
                <div class="row-input">
                    <ul>
                        <li>融资中:<a href="javascript:loaningNavTab();">${loaningCount}</a></li>
                    </ul>
                </div>
                <div class="row-input">
                    <table class="table table-bordered">
                        <thead>
                        <tr>
                            <td align="center">标的名称</td>
                            <td align="center">标的编号</td>
                            <td align="center">借款人</td>
                            <td align="center">借款金额</td>
                            <td align="center">已融资</td>
                            <td align="center">剩余</td>
                        </tr>
                        </thead>
                        <tbody>
                        <c:set var="loanAmountD_sum" value="0"/>
                        <c:set var="currentAmountD_sum" value="0"/>
                        <c:forEach items="${pagingLoanByLoaning.list}" var="loaningLoan">
                            <tr>
                                <td>${loaningLoan.fullName}</td>
                                <td>${loaningLoan.loanNumber}</td>
                                <td>
                                    <a href="javascript:userInfo(${loaningLoan.userId},'${loaningLoan.userName}');">
                                            ${loaningLoan.userName}
                                    </a>
                                </td>
                                <td>${loaningLoan.loanAmountD}</td>
                                <td>${loaningLoan.currentAmountD}</td>
                                <td>${loaningLoan.loanAmountD-loaningLoan.currentAmountD}</td>
                            </tr>
                            <c:set value="${loanAmountD_sum + loaningLoan.loanAmountD}" var="loanAmountD_sum"/>
                            <c:set value="${currentAmountD_sum + loaningLoan.currentAmountD}" var="currentAmountD_sum"/>
                        </c:forEach>
                        </tbody>
                        <tfoot>
                        <tr>
                            <td colspan="5"></td>
                            <td>
                                <a href="javascript:loaningNavTab();">更多...</a>
                            </td>
                        </tr>
                        <tr>
                            <td>合计:</td>
                            <td colspan="2"></td>
                            <td><fmt:formatNumber value="${loanAmountD_sum}" pattern="####0.00"/></td>
                            <td><fmt:formatNumber value="${currentAmountD_sum}" pattern="####0.00"/></td>
                            <td><fmt:formatNumber value="${loanAmountD_sum-currentAmountD_sum}"
                                                  pattern="####0.00"/></td>
                        </tr>
                        </tfoot>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">
                用户
            </h3>
        </div>

        <div data-layout-h="0" class="bjui-row col-2">
            <div class="row-input">
                <ul>
                    <li>
                        今日注册人数：${r_day}
                    </li>
                    <li>
                        7天注册人数：${r_week}
                    </li>
                    <li>
                        30天注册人数：${r_month}
                    </li>
                </ul>
            </div>
            <div class="row-input">
                <ul>
                    <li>
                        今日登录人数：${l_day}
                    </li>
                    <li>
                        7天登录人数：${l_week}
                    </li>
                    <li>
                        30天登录人数：${l_month}
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="/js/loan/loanDisplay.js"></script>
<script>
    function repayingNavTab() {
        loanNavTab("returningLoan", "returning", "还款中");
    }

    function fullPayNavTab() {
        loanNavTab("fullPay", "fullPay", "满标待放款");
    }

    function riverNavTab() {
        loanNavTab("riverLoan", "river", "流标待退款");
    }

    function firstCheckNavTab() {
        loanNavTab("firstCheckLoan", "firstCheck", "发标待审");
    }

    function loaningNavTab() {
        loanNavTab("loaningLoan", "loaning", "融资中");
    }

    //上面的id都是从sysconfig中拷贝过来的
    function loanNavTab(id, url, title) {
        BJUI.navtab({
            id: id,
            url: "/admin/loan/loan/" + url,
            title: title
        })
    }
</script>